var usuarioTable;

function serverList() {
    $('<a class="_hootified" a="" href="#" #area_table"="" onclick="javascript:var e = document.createEvent("CustomEvent"); e.initCustomEvent("hootletEvent", true, true, {type: "hash", value: "#area_table"});  document.body.dispatchEvent(e); return false;">#usuario_table</a>').dataTable({
        "bProcessing": true,
        "bServerSide": true,
        "sAjaxSource": "/admin/usuario/list"
    });
}

function list() {
    $.ajax({
        url: '/admin/usuario/list',
        type: 'post',
        dataType: 'json',
        success: function(response) {
            // se traen los datos al cargar la pagina
            areaTable = $('#usuario_table').dataTable({
                "sDom": "<'nuevo'> frtip",
                "sPaginationType": "bootstrap",
                bLengthChange: false,
                "oLanguage": {
                    "sLengthMenu": "_MENU_ records per page"
                },
                "aaData": response,
                "aoColumns": [
                    {
                        "sTitle": ""
                    },
                    {
                        "sTitle": "Username"
                    },
                    {
                        "sTitle": "Nombre y apellido"
                    }
                ]
            });
            $("div.nuevo").html('<button id="new" class="btn btn-large btn-primary" onclick="nuevo();" type="button" name="new">Nuevo</button>');
            $.unblockUI();
        },
        error: function(event, request, settings) {
            $.unblockUI();
            alert("Error");
        }
    });

}

$(document).ready(function() {

    $.blockUI({
        message: "Aguarde un momento por favor"
    });
    list();
});
